<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户注册</title>
    <link rel="stylesheet" href="register.css">

</head>

<body>
    <div class="box">
        <h3>用户注册</h3>
        <div class="user">
            <p>
                <span class="cls same choose">患者</span>
                <span class="cls same">医院管理人员</span>
                <span class="cls same">医生</span>
                <span class="cls same">系统管理员</span>
            </p>
        </div>
        <div class="content">
            <form action="" method="" class="patient people chice">
                <div>
                    <input type="text" placeholder="请输入用户名">
                </div>
                <div>
                    <input type="password" placeholder="请输入密码">
                </div>
                <div>
                    <span class="sex">性别</span>
                    <span>男</span><input type="radio" name="sex" class="sex1" style="margin-right: 30px;">
                    <span>女</span><input type="radio" name="sex" class="sex1">
                </div>
                <div>
                    <input type="text" placeholder="请输入真实姓名">
                </div>
                <div>
                    <input type="text" placeholder="请输入卡号">
                </div>
                <div>
                    <input type="text" placeholder="请输入年龄">
                </div>
                <div>
                    <input type="number" oninput="if(value.length > 11) value = value.slice(0, 11)" placeholder="请输入手机号码">
                </div>
                <div>
                    <input type="text" placeholder="请输入验证码">
                    <button value="获取验证码">获取验证码</button>
                </div>
                <div> 
                    <input type="submit" value="注册">
                </div>
            </form>

            <form action="" method="" class="hospital people ">
                <div>
                    <input type="text" placeholder="请输入用户名">
                </div>
                <div>
                    <input type="password" placeholder="请输入密码">
                </div>
                <div>
                    <input type="number" oninput="if(value.length > 11) value = value.slice(0, 11)" placeholder="请输入手机号码">
                </div>
                <div>
                    <input type="text" placeholder="请输入验证码">
                    <button value="获取验证码">获取验证码</button>
                </div>
                <div> 
                    <input type="submit" value="注册">
                </div>
            </form>

            <form action="" method="" class="doctor people">
                <div>
                    <input type="text" placeholder="请输入用户名">
                </div>
                <div>
                    <input type="password" placeholder="请输入密码">
                </div>
                <div>
                    <input type="number" oninput="if(value.length > 11) value = value.slice(0, 11)" placeholder="请输入手机号码">
                </div>
                <div>
                    <input type="text" placeholder="请输入验证码">
                    <button value="获取验证码">获取验证码</button>
                </div>
                <div> 
                    <input type="submit" value="注册">
                </div>
            </form>

            <form action="" method="" class="administrator people ">
                <div>
                    <input type="text" placeholder="请输入用户名">
                </div>
                <div>
                    <input type="password" placeholder="请输入密码">
                </div>
                <div>
                    <input type="number" oninput="if(value.length > 11) value = value.slice(0, 11)" placeholder="请输入手机号码">
                </div>
                <div>
                    <input type="text" placeholder="请输入验证码">
                    <button value="获取验证码">获取验证码</button>
                </div>
                <div>  
                    <input type="submit" value="注册">
                </div>
            </form>
        </div>
    </div>
</body>
    <script>
        var btns = document.querySelectorAll('.cls'); 
        var forms = document.querySelectorAll('.people');
        console.log(btns);
        console.log(forms);
        for (var i = 0; i < btns.length; i++) {
            btns[i].index = i;
            btns[i].onclick = function() {
                for (var k = 0; k < btns.length; k++) {
                    btns[k].classList.remove('choose');
                }
                btns[this.index].classList.add('choose');
                for (var j = 0; j < forms.length; j++) {
                    forms[j].classList.remove('chice');
                }
                forms[this.index].classList.add('chice');
            }
        }
    </script>
</html>